<script>
  document.getElementById('demo').onclick = function () {
    console.log('单击');
  };
</script>
<div id="demo">测试</div>